/*
 * Copyright © 2024-2025 Wenze Wei
 *
 * This file is part of StadionOS.
 *
 * This Source Code Form is subject to the terms of the GNU General Public License, v. 2.0.
 * You can obtain a copy of the GPL at
 * https://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 */

#include "../include/math.h"

/**
 * @brief Calculates the power of a double to another double.
 *
 * This function returns the value of x raised to the power of y.
 * It returns NAN if x is negative and y is not an integer.
 *
 * @param x The base double value.
 * @param y The exponent double value.
 * @return double The result of x raised to the power of y.
 */
double Spow(double x, double y) {  
    if (x < 0 && (y - (int)y) != 0)
        return DNAN;

    return Sexp(y * Slog(x));  
}
